<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateWaybillsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('waybills', function (Blueprint $table) {
            $table->id();
            $table->string('order_no',50)->index()->comment('订单编号');
            $table->string('express_no',50)->nullable()->comment('运单号');
            $table->string('goods_name', 255)->nullable()->comment("商品名称");
            $table->string('goods_bn', 255)->nullable()->comment("商品编号");
            $table->string('part_bn', 255)->nullable()->comment("料号");
            $table->integer('goods_num')->default(0)->comment("商品数量");
            $table->string('consignee_name',150)->nullable()->comment('收货人姓名');
            $table->longtext('consignee_address')->nullable()->comment('详细地址');
            $table->string('supplier_name',255)->nullable()->comment('供应商账号名');
            $table->string('seller_name',100)->nullable()->comment('店铺卖家');
            $table->float('order_amount',8,2)->default(0)->comment('订单总价');
            $table->unsignedTinyInteger('declare_status')->default(0)->comment("清单申报状态: 0、待申报 1、已申报");
            $table->unsignedTinyInteger('status')->default(0)->comment("订单状态: 0、待下单, 1、下单中,等待回执，2、订单取消成功");
            $table->unsignedTinyInteger('platform_delivery_status')->default(0)->comment("平台发货状态: 0、未发货, 1、已发货, 2、订单取消, 3、下单中,等待回执");
            $table->unsignedTinyInteger('warehouse_delivery_status')->default(0)->comment("仓库发货状态: 0、未发货, 1、已发货, 2、部分发货, 3、已退货, 4、部分退货");
            $table->string('clearance_type',50)->nullable()->comment('清关类型');
            $table->float('goods_price',8,2)->default(0)->comment('商品单价');
            $table->float('cost_amount',8,2)->default(0)->comment('成本价');
            $table->float('profit_amount',8,2)->default(0)->comment('利润');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('waybills');
    }
}
